Skip to content

fix: add ArgumentNullException guards to BaseReflectionConverter#74

Merged
IvanMurzak merged 2 commits into
mainfrom
feat/null-guard-exceptions
Mar 25, 2026
Merged

fix: add ArgumentNullException guards to BaseReflectionConverter#74
IvanMurzak merged 2 commits into
mainfrom
feat/null-guard-exceptions

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

@IvanMurzak IvanMurzak commented Mar 25, 2026

Summary

  • Replace uninformative NullReferenceException with explicit ArgumentNullException(nameof(...)) across all BaseReflectionConverter<T> entry points
  • Guards added to 12 methods across 4 partial files: TryModify, TryModifyField, TryModifyProperty, Serialize, SerializeFields, SerializeProperties, Deserialize, TryDeserializeValue, TryDeserializeValueInternal, DeserializeValueAsJsonElement, CreateInstance, GetDefaultValue
  • Parameters guarded: reflector, data/fieldValue/propertyValue, type/objType, obj (where non-nullable)

Context

Intermittent NullReferenceException: Object reference not set to an instance of an object in TryModify with certain data models gave no indication of which parameter was null. Now the exception message explicitly names the null argument.

Test plan

  • dotnet build --configuration Release — passes
  • dotnet test --configuration Release — all 1355 tests pass
  • Verify improved exception messages appear when null arguments are passed at runtime

🤖 Generated with Claude Code

…y points

Replace cryptic NullReferenceExceptions with explicit ArgumentNullException
throwing the parameter name. Guards added to TryModify, TryModifyField,
TryModifyProperty, Serialize, SerializeFields, SerializeProperties,
Deserialize, TryDeserializeValue, TryDeserializeValueInternal,
DeserializeValueAsJsonElement, CreateInstance, and GetDefaultValue.
@IvanMurzak IvanMurzak self-assigned this Mar 25, 2026
@IvanMurzak IvanMurzak added the bug Something isn't working label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 25, 2026

Test Results

    2 files      2 suites   9m 1s ⏱️
1 355 tests 1 355 ✅ 0 💤 0 ❌
2 710 runs  2 710 ✅ 0 💤 0 ❌

Results for commit 1087054.

♻️ This comment has been updated with latest results.

@IvanMurzak IvanMurzak merged commit 3545ebb into main Mar 25, 2026
2 checks passed
@IvanMurzak IvanMurzak deleted the feat/null-guard-exceptions branch March 25, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant